package com.abc.mapper;


import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: bc
 * @Date: 2024-11-17 12:34
 * @Description:
 */
public interface KcyhMapper {
    @Select("<script>" +
        "SELECT " +
        "bunk.id AS cwid ,bunk.bunk_number AS cwbh " +
        ",patient.id AS hzid,patient.patient_id AS hzbh,patient.patient_name AS hzxm " +
        ",doctor.id AS ysid,doctor.doctor_id AS ysbh,doctor.doctor_name AS ysxm " +
        ",department.id AS ksid,department.department_name AS ksmc " +
        " FROM kcyh AS aaa " +
        " LEFT JOIN bunk ON  aaa.c_id = bunk.id " +
        "LEFT JOIN patient ON aaa.h_id = patient.id " +
        "LEFT JOIN doctor ON aaa.y_id = doctor.id " +
        "LEFT JOIN department ON aaa.k_id = department.id " +
        "<where>" +
        "<if test='patientId!=null and patientId!=\"\"'>" +
        "and patient.id  = #{patientId} " +
        "</if>" +
        "</where>"+
        "</script>")
    List<Map<String,Object>> selectKcyhByPatientId(@Param("patientId") String patientId);
    @Insert("INSERT INTO kcyh(c_id,h_id,y_id,k_id) VALUES(#{cid},#{hid},#{yid},#{kid})")
    int insertKcyh(Map<String,Object> map);
    @Update("UPDATE kcyh SET c_id = #{cid},y_id = #{yid},k_id = #{kid} WHERE h_id = #{hid}")
    int updateKcyh(Map<String,Object> map);
}
